<?php
include "header.php";
?>
<script>change_picture("calculator");</script>
<div>
<h1>Course Schedule Calculator</h1>
<div class = "step_nav">
<a href = "#" onclick = "submit_form('calculator_1.php');"><div id = "step_1" class = "step_button step_on" ></div></a>
<a href = "#" onclick = "submit_form('calculator_2.php');"><div id = "step_2" class = "step_button step_on" ></div></a>
<a href = "#" onclick = "submit_form('calculator_3.php');"><div id = "step_3" class = "step_button step_on" ></div></a>
<a href = "#" onclick = "submit_form('calculator_4.php');"><div id = "step_4" class = "step_button step_off" ></div></a>
</div>
<div class = "step_text">Enter your course information for taken/transfer courses and desired courses.</div>
<div class = "form_field">
<form id = "courseinfo_form" method = "POST">
<div>
<?php
/*
if ($_POST["specifycredits"] !== ""){
	$specifycredits = explode(",", $_POST["specifycredits"]);
	foreach ($specifycredits as $item){
		echo $item.", ";
	}
}
else{
	echo "no got";
}
*/
?>
</div>
<div>
<table>
<thead>
<tr><td>Course</td><td>Requirement to meet</td><td>Course State</td><td>Year</td><td>Term</td><td>Operation</td></tr>
</thead>
<tbody>
<tr id = "course_info" class = "input_tr">
<td><div id = "course_name">(NULL)</div><input type = "button" id = "select_course" value = "Select a Course" onclick = "show_select_course();"/></td>
<td><select id = "requirement_name" disabled><option>(NULL)</option></select></td>
<td><input type = "radio" name = "course_state" value = "taken" id = "taken_0" disabled /><label for = "taken_0" class = "simple_label disabled">Taken or Transfered</label><br /><input type = "radio" name = "course_state" value = "desire" id = "desire_0" disabled /><label for = "desire_0" class = "simple_label disabled">Desire to Take</label></td>
<td><select id = "course_year" disabled><option value = "(Unspecified)">(Unspecified)</option></select></td>
<td><select id = "course_term" disabled><option value = "(Unspecified)">(Unspecified)</option></select></td>
<td><input type = "button" id = "add_course_info" value = "Add" disabled /></td>
</tr>
</tbody>
</table>
</div>
<div class = "next_back">
<a href = "#" onclick = "submit_form('calculator_4.php');"><div class = "next button"></div></a>
<a href = "#" onclick = "submit_form('calculator_2.php');"><div class = "back button"></div></a>
</div>
</form>
</div>
</div>
<script>
var list = new Array();
var currentPage;
var currentCourse;
function show_select_course(){
	search_course(currentPage);
	$('#select_course_list').show();
	$('#select_course_list').css("left", $(".page").offset().left+35);
}
function hide_select_course(){
	$('#select_course_list').hide();
}
function search_course(n){
	$.post("searchcourses.php",
	{
		prefix:$("#search_prefix").val(),
		number:$("#search_number").val(),
		title:$("#search_title").val(),
		course_list:list,
		current_course:currentCourse,
		page:n,
	},
	function(data,status){
		$("#search_result").html(data);
		currentPage = n;
		css_format();
	});
}
function select_course(id, prefix, number, title){
	hide_select_course();
	currentCourse = id;
	$("#course_name").html(prefix + " " + number);
	if ($("#course_name").html() == " "){
		$("#course_name").html("(NULL)");
	}
	else{
		/*$.post("searchrequirements_bycourse.php",
		{
			c_id:id;
		},
		function(data, status){
			$("#requirement_name").html(data);
		});*/
		$("#requirement_name").removeAttr("disabled");
		$("#taken_0").removeAttr("disabled");
		$(".simple_label").removeClass("disabled");
		$("#desire_0").removeAttr("disabled");
		$("#course_year").removeAttr("disabled");
		$("#course_term").removeAttr("disabled");
		$("#add_course_info").removeAttr("disabled");
	}
}
function submit_form(action_url){
	$("#courseinfo_form").attr("action", action_url);
	$('#courseinfo_form').submit();
}
</script>
<div id = "select_course_list">
<div style = "text-align:right;">
<a href = "javascript:" onclick = "hide_select_course();"><div class = "close_button">CLOSE<img src = "images/close.png" /></div></a>
</div>
<div style = "padding: 20px 0px 10px 0px;">
<label for = "search_prefix">Prefix: </label><input type = "text" id = "search_prefix" style = "width:100px;"/>
<label for = "search_number">Number: </label><input type = "text" id = "search_number" style = "width:120px;"/>
<label for = "search_title">Title: </label><input type = "text" id = "search_title" style = "width:350px;"/>
</div>
<a href = "javascript:" onclick = "search_course(0);"><div class = "search_button button" ></div></a>
<div id = "search_result"></div>
</div>
<?php
include "footer.php";